// npm i react-router-dom
import {
  RouterProvider, //路由提供器
  createHashRouter//创建哈希路由 createBrowserRouter
} from 'react-router-dom'
import Root from '../views/Root'
import HomeView from '../views/HomeView'
import UserView from '../views/UserView'
import ProduceView from '../views/ProduceView'
// 路由配置
const routes = [
  {path:"/",element:<Root/>,
    children:[
      {path:'',element:<HomeView/>},
      {path:"user",element:<UserView/>},
      {path:"produce/:id",element:<ProduceView/>}
    ]},
  {path:"/about",element:<div>关于我们</div>}
]

function RouterView(){
    // 创建一个哈希路由
    const router = createHashRouter(routes);
    // 给路由提供器router
    return <RouterProvider router={router}/>
}
export default RouterView;